﻿﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SongBuilder
{
	public class Bar
	{
		private List<Note> notes = new List<Note>();

		public Bar(params Note[] notes)
		{
			if (notes.Count() != 4)
				throw new InvalidOperationException();

			this.notes.AddRange(notes);
		}

		public IEnumerable<Note> Notes { get { return this.notes; } }

		public void Play(int duration)
		{
			for (int x = 0; x < 4; x++)
				this.notes[x].Play(duration);
		}

		public override string ToString()
		{
			StringBuilder sb = new StringBuilder();
			for (int x = 0; x < 4; x++)
			{
				if (x > 0)
					sb.Append(" ");

				sb.Append(this.notes[x].ToString());
			}

			return sb.ToString();
		}
	}
}